package xyf.p04.tree;

import commons.TreeNode;

/**
 * ClassName: P0104_MaxDepth
 * Description:
 * Author: xyf
 * Date: 9/7/22 8:34 PM
 * Version: 1.0
 **/
public class P0104_MaxDepth
{
    public int maxDepth(TreeNode root)
    {
        if (root == null)
        {
            return 0;
        }
        int leftDepth = maxDepth(root.left);
        int rightDepth = maxDepth(root.right);
        return Math.max(leftDepth, rightDepth) + 1;
    }
}
